package aop10;

import org.aspectj.lang.ProceedingJoinPoint;

public class TimeAdvice {

    public Object time(ProceedingJoinPoint jp)throws Throwable{
        Object proxy=jp.getThis();
        Object target=jp.getTarget();
        String methodName=jp.getSignature().getName();
        Object[] args=jp.getArgs();


        Object result=null;
        long start=0;
        long end=0;

        try {
            System.out.println("start");
            start=System.currentTimeMillis();

            result=jp.proceed();

            end=System.currentTimeMillis();
            System.out.println("end");


        } catch (Exception e) {
            end=System.currentTimeMillis();
            System.out.println("error");
            throw e;
        } finally {
            System.out.println(methodName+" "+(end-start));
        }
        return result;

    }


}
